package bancosys.tec.rtm.impl.diagnostician;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;

import bancosys.tec.rtm.diagnostician.AbstractDiagnostician;
import bancosys.tec.rtm.diagnostician.DiagnosisBean;

/**
 * Devolve as informacoes disponiveis pelo {@link RuntimeMXBean}
 * 
 * @author takeshi
 */
public class JMXSystemRuntimeDiagnostician extends AbstractDiagnostician {

    /**
     * {@inheritDoc}
     */
    public String getName() {
        return "JMX Runtime";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected boolean fillDiagnosisBean(DiagnosisBean bean) {
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        bean.addDescription("vm name: " + runtimeMXBean.getName() + "\n");
        bean.addDescription("start time: " + new Date(runtimeMXBean.getStartTime()) + "\n");
        bean.addDescription("uptime: " + runtimeMXBean.getUptime() + "ms \n");
        bean.addDescription("boot classpath: " + runtimeMXBean.getBootClassPath() + "\n");
        bean.addDescription("classpath: " + runtimeMXBean.getClassPath() + "\n");
        bean.addDescription("library path: " + runtimeMXBean.getLibraryPath() + "\n");
        bean.addDescription("JMX spec version: " + runtimeMXBean.getManagementSpecVersion() + "\n");
        return true;
    }

}
